package com.project.bean;
import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.time.LocalDate;
import java.util.List;

/**
 * 订单实体类
 */
public class OrderBean {
    /**编号*/
    private int id;
    /**收件人*/
    @NotBlank(message = "姓名不能为空")
    private String receiver;
    /**地址*/
    @Pattern(regexp = "[0-9\\u4e00-\\u9fa5]{5,}",message = "地址必须是5位以上的汉字或数字")
    private String address;
    /**电话*/
    @Pattern(regexp = "1[3578]\\d{9}",message = "电话必须是13、15-、17、18开头的数字")
    private String phone;
    /**状态*/
    private String status = "未发货";
    /**下单用户*/
    private UserBean user;
    /**下单时间*/
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate date = LocalDate.now();
    /**订单明细集合*/
    private List<InfoBean> infoList;
    /**订单金额*/
    private int orderMoney;

    public OrderBean() {
    }

    public OrderBean(String receiver, String address, String phone,  int orderMoney, int  userId) {
        this.receiver = receiver;
        this.address = address;
        this.phone = phone;
        this.orderMoney = orderMoney;
        this.user = new UserBean();
        this.user.setId(userId);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public UserBean getUser() {
        return user;
    }

    public void setUser(UserBean user) {
        this.user = user;
    }

    public LocalDate getDate() {
        return date;
    }

    public void setDate(LocalDate date) {
        this.date = date;
    }

    public List<InfoBean> getInfoList() {
        return infoList;
    }

    public void setInfoList(List<InfoBean> infoList) {
        this.infoList = infoList;
    }

    public int getOrderMoney() {
        return orderMoney;
    }

    public void setOrderMoney(int orderMoney) {
        this.orderMoney = orderMoney;
    }

    @Override
    public String toString() {
        return "OrderBean{" +
                "id=" + id +
                ", receiver='" + receiver + '\'' +
                ", address='" + address + '\'' +
                ", phone='" + phone + '\'' +
                ", status='" + status + '\'' +
                ", user=" + user +
                ", date=" + date +
                ", infoList=" + infoList +
                ", orderMoney=" + orderMoney +
                "}\n";
    }
}
